<!-- 回款免责申请单 -->
<template>
  <view>
    <u-form
      :model="model"
      :rules="rules"
      ref="form"
      labelPosition="top"
      labelWidth="auto"
      :labelStyle="{
        fontSize: '14px',
        color: '#B2B2B2',
        lineHight: '20px',
      }"
    >
      <view class="basic-style">
        <view class="basic-title basic-border">基本信息</view>
        <u-form-item label="单据编号" prop="billNo" required>
          <u--input v-model="model.billNo" disabled></u--input>
        </u-form-item>
        <u-form-item label="申请时间" prop="createTime" required>
          <u--input v-model="model.createTime" disabled></u--input>
        </u-form-item>
        <u-form-item label="申请人" prop="proposer" required>
          <h-select-person-input
            style="width: 100%"
            disabled
            v-model="model.proposer"
            placeholder="请选择申请人"
            border="surround"
            suffixIcon="arrow-down-fill"
            :suffixIconStyle="{ color: '#B2B2B2' }"
            objectField="model.proposer"
          ></h-select-person-input>
        </u-form-item>
        <u-form-item label="申请部门" prop="proposerDeptId" required>
          <h-select-depart-input
            disabled
            v-model="model.proposerDeptId"
            :departName="model.proposerDeptIdText"
            placeholder="请选择部门"
            border="surround"
            style="width: 100%"
            suffixIcon="arrow-down-fill"
            :suffixIconStyle="{ color: '#B2B2B2' }"
            :title.sync="model.proposerDeptIdText"
          ></h-select-depart-input>
        </u-form-item>
      </view>

      <view class="basic-style">
        <view class="basic-title basic-border pt-1">项目信息</view>
        <u-form-item label="项目名称" prop="projectId" required>
          <h-select-project-input-popup
            :api="queryDistributionProjectList"
            :proDisabled="true"
            :projectStatus="'2'"
            ref="projectSelect"
            v-model="model.projectId"
            style="width: 100%"
            placeholder="请选择项目名称"
            border="surround"
            suffixIcon="arrow-down-fill"
            :suffixIconStyle="{ color: '#B2B2B2' }"
          ></h-select-project-input-popup>
          <!-- @change="projectChangeHandle" -->
        </u-form-item>
        <u-form-item label="项目编号" prop="projectNo">
          <u--input disabled placeholder="请输入项目编号" v-model="model.projectNo"></u--input>
        </u-form-item>
        <u-form-item label="项目承接人" prop="undertaker">
          <h-select-person-input-popup
            disabled
            v-model="model.undertaker"
            style="width: 100%"
            placeholder="请选择项目承接人"
            searchPlaceholder="请输入"
            border="surround"
            suffixIcon="arrow-down-fill"
            :suffixIconStyle="{ color: '#B2B2B2' }"
          ></h-select-person-input-popup>
        </u-form-item>
        <u-form-item label="经营团队" prop="managementTeam">
          <h-select-team-input
            disabled
            style="width: 100%"
            v-model="model.managementTeam"
            objectField="model.managementTeam"
            placeholder="请选择经营团队"
            border="surround"
            :tdlx="1"
          />
        </u-form-item>
        <u-form-item label="业绩归属年度" prop="year">
          <h-select-input-tag
            disabled
            class="w-100"
            v-model="model.year"
            objectField="model.year"
            placeholder="请选择业绩归属年度"
            border="surround"
            dictName="yjgsnd"
          ></h-select-input-tag>
        </u-form-item>
        <u-form-item label="签订单位" prop="signUnit">
          <h-select-company-input-popup
            disabled
            style="width: 100%"
            v-model="model.signUnit"
            commercialType="1"
            placeholder="请选择公司"
            border="surround"
          ></h-select-company-input-popup>
        </u-form-item>
        <u-form-item label="业主单位" prop="ownerUnit">
          <h-select-customer-input-popup
            disabled
            style="width: 100%"
            v-model="model.ownerUnit"
            objectField="model.ownerUnit"
            commercialType="1"
            placeholder="请选择业主单位"
            border="surround"
          ></h-select-customer-input-popup>
        </u-form-item>
        <u-form-item label="合同名称" prop="contractId" required>
          <h-select-contract-manager-input-popup
            disabled
            :status="'2'"
            :allList="true"
            :signUnit="model.signUnit"
            :muitFlag="true"
            v-model="model.contractId"
            :contact-name.sync="model.contractName"
            placeholder="请选择合同名称"
            border="surround"
            style="width: 100%"
            suffixIcon="arrow-down-fill"
            :suffixIconStyle="{ color: '#B2B2B2' }"
          ></h-select-contract-manager-input-popup>
        </u-form-item>
        <u-form-item label="合同额(元)" prop="contractAmount">
          <u--input disabled type="number" v-number-normal placeholder="请输入合同额" v-model="model.contractAmount"></u--input>
        </u-form-item>
        <u-form-item label="实收款总额（元）" prop="totalAmountReceived">
          <u--input disabled placeholder="请输入实收款总额（元）" v-model="model.totalAmountReceived"></u--input>
        </u-form-item>
        <u-form-item label="无法按期回款原因" prop="reason" required>
          <u--textarea maxlength="500" :confirm-type="null" count v-model="model.reason" placeholder="请输入无法按期回款原因"></u--textarea>
        </u-form-item>
      </view>

      <view class="basic-style">
        <view class="basic-title basic-border pt-1">任务信息</view>
        <TaskInfo :dictOptions="dictOptions" :entities="taskDataSource" />
      </view>

      <view class="basic-style">
        <view class="basic-title basic-border pt-1">免责信息</view>
        <view class="space-y-1 py-1">
          <u-button size="small" type="primary" @click="handleAddMember">新增</u-button>
        </view>
        <u-collapse ref="collapseView">
          <u-collapse-item
            :title="filterMultiDictText(dictOptions['paymentName'], item.paymentName + '')"
            v-for="(item, index) in formData"
            :key="index"
          >
            <FormInfo
              :dictOptions="dictOptions"
              :item="item"
              :index="index"
              @edit="handleEditForm"
              @remove="handleRemoveForm"
              @copy="handleCopyForm"
            />
          </u-collapse-item>
        </u-collapse>
        <u-popup :round="10" mode="bottom" :show="showFormModal" :closeOnClickOverlay="false">
          <PaybackDisclaimerForm
            ref="dataForm"
            :dictOptions="dictOptions"
            :projectId="model.projectId"
            :contractId="model.contractId"
            :managementTeam="model.managementTeam"
            :undertaker="model.undertaker"
            :projectLeadingToSubTableText="projectLeadingToSubTableText"
            :projectLeadingToSubTable="projectLeadingToSubTable"
            :index="index"
            @submit="handleFormSubmit"
            @close="closeFormModal"
          />
        </u-popup>
      </view>

      <view class="basic-style">
        <view class="basic-title basic-border">任务附件</view>
        <view class="py-1 space-y-1" style="width: 100%">
          <view style="color: red">提示：请等待附件上传完成，再点击保存，否则附件无法保存成功！</view>
          <h-upload-file v-model="model.taskFile" :isIcon="false"></h-upload-file>
          <file-list v-if="model.taskFile" v-model="model.taskFile" :isDelete="true"></file-list>
        </view>
      </view>
      <view class="space-x-1 px-1 btn_position">
        <u-button :disabled="isSubmit" type="primary" :plain="true" text="保存" @click="onDraft"></u-button>
        <u-button :disabled="isSubmit" type="primary" text="保存并提交" @click="onSubmit"></u-button>
      </view>
      <view style="height: 100rpx"></view>
      <u-toast ref="uToast"></u-toast>
      <ProcessNodeConfiguration ref="processConfig" @ok="onOk"></ProcessNodeConfiguration>
    </u-form>
  </view>
</template>
    
    <script>
import { mapState } from 'vuex'
import moment from 'moment'
// import Decimal from 'decimal.js'
import {
  gainBillNo,
  add,
  edit,
  info,
  queryTaskInfoList,
  queryContractFinal,
  listForAudit,
  queryPageList,
  queryDisclaimerDetailList,
} from '@/api/audit/PaybackDisclaimerForm.js'
import { queryDistributionProjectList } from '@/api/index'
import { filterMultiDictText, initDictOptions } from '@/utils/JDictSelectUtil.js'
import fileList from '@/pages/synergy/components/fileList.vue'
import PaybackDisclaimerForm from './components/PaybackDisclaimerForm.vue'
import FormInfo from './components/PaybackDisclaimerFormInfo.vue'
import TaskInfo from './components/TaskInfo.vue'
import ProcessNodeConfiguration from '@/components/ProcessNodeConfiguration/ProcessNodeConfiguration.vue' // 流程节点配置人员选择弹窗

export default {
  name: 'PaybackDisclaimerForm',
  components: {
    fileList,
    PaybackDisclaimerForm,
    FormInfo,
    TaskInfo,
    ProcessNodeConfiguration,
  },
  data() {
    return {
      filterMultiDictText,
      queryDistributionProjectList,
      isSubmit: false, // 控制按钮是否可以点击
      index: null,
      showFormModal: false,
      loading: false,
      id: '',
      basicForm: {},
      dictOptions: {},
      formData: [],
      taskDataSource: [],
      model: {
        bpmBizTitle: '',
        billNo: '',
        createTime: '',
        proposer: '',
        proposerDeptId: '',
        productTeam: '',
        projectId: '',
        projectNo: '',
        undertaker: '',
        managementTeam: '',
        year: '',
        signUnit: '',
        ownerUnit: '',
        contractId: '',
        contractAmount: '',
        totalAmountReceived: '',
        reason: '',
        attachments: null,
      },
      rules: {
        billNo: [{ required: true, message: '请输入单据编号!', trigger: ['blur', 'change'] }],
        proposerDeptId: [{ required: true, message: '请选择申请部门!', trigger: ['blur', 'change'] }],
        proposer: [{ required: true, message: '请选择申请人!', trigger: ['blur', 'change'] }],
        createTime: [{ required: true, message: '请选择申请时间!', trigger: ['blur', 'change'] }],
        projectId: [{ required: true, message: '请选择项目名称!', trigger: ['blur', 'change'] }],
        reason: [{ required: true, message: '请输入无法按期回款原因!', trigger: ['blur', 'change'] }],
      },
      projectLeadingToSubTable: '',
      projectLeadingToSubTableText: '',
      projectIdBackups: null,
      //代码生成后需手动设置流程编码
      flowCode: 'onl_erp_payback_disclaimer',
      formUrl: 'erp/audit/paybackDisclaimer/modules/PaybackDisclaimerForm',
      formUrlMobile: '/pages/synergy/PaybackDisclaimerForm',
      beanName: 'erpPaybackDisclaimerServiceImpl',
    }
  },
  onLoad({ id }) {
    this.id = id || ''
  },
  onReady() {
    this.$refs.projectSelect.$on('change', (event) => {
      this.projectChangeHandle(event)
    })
  },
  onUnload() {
    this.$off('change')
  },
  created() {
    if (this.id) {
      this.initInfo()
      this.initDataList()
      this.initDisclaimerDetailList()
    } else {
      this.initForm()
      this.initBillNo()
    }
    this.initDictConfig()
  },
  computed: {
    ...mapState(['userInfo']),
  },
  methods: {
    // 提交流程成功
    onOk() {
      this.$refs.uToast.show({
        message: '提交成功',
        type: 'success',
        complete() {
          if (getCurrentPages().length > 1) {
            uni.navigateBack()
          } else {
            uni.reLaunch({
              url: '/pages/home/home',
            })
          }
        },
      })
    },

    async projectChangeHandle(data) {
      if (!data) {
        return
      }
      let backItem = data
      //时间关系 先下面的垃圾代码复制过来用着，有空再提取
      if (!this.projectIdBackups) {
        this.projectIdBackups = this.model.projectId

        this.projectLeadingToSubTable = ''
        this.projectLeadingToSubTableText = ''
        this.taskDataSource = []

        //带出项目编号
        this.$set(this.model, 'projectNo', backItem.finalNo)

        //带出项目真实名称
        this.$set(this.model, 'projectName', backItem.projectName)

        //带出项目承接人
        this.$set(this.model, 'undertaker', backItem.undertaker)

        //带出经营团队
        this.$set(this.model, 'managementTeam', backItem.teamName)

        //带出业绩归属年度
        this.$set(this.model, 'year', backItem.year)

        //带出签订单位
        this.$set(this.model, 'signUnit', backItem.signUnit)

        //带出业主单位
        this.$set(this.model, 'ownerUnit', backItem.ownerUnit)

        //请求合同档案
        queryContractFinal({ xmmc: backItem.id, htlx: 1 }).then((res) => {
          if (res.success) {
            if (res.result.records.length > 0) {
              //查出收款合同
              this.$set(this.model, 'contractId', res.result.records[0].id)
              //带出合同真实名称
              this.$set(this.model, 'contractName', res.result.records[0].htmc)
              //带出本次合同额
              this.$set(this.model, 'contractAmount', res.result.records[0].bchte)

              var contractIdTemp = res.result.records[0].id
              //查询收款进度中节点信息
              listForAudit({ contractId: contractIdTemp, contractType: '1' }).then((res) => {
                if (res.success) {
                  let { records } = res.result
                  if (records && records.length > 0) {
                    let firstItem = records[0]
                    //从进度管理-收款进度主表中带出实收款总额
                    this.$set(this.model, 'totalAmountReceived', firstItem.realCollectionPaymentMoney)
                  }
                }
              })
            } else {
              //没有收款合同则收款合同带出的信息置空
              this.$set(this.model, 'contractId', '') //合同id置空
              this.$set(this.model, 'contractName', '') //合同名称置空
              this.$set(this.model, 'contractAmount', '') //本次合同额置空
              this.$set(this.model, 'totalAmountReceived', '') //收款进度-实收款总额置空
            }
          }
        })

        //请求任务档案根据项目id
        queryPageList({ projectId: backItem.id }).then((res) => {
          if (res.success) {
            if (res.result.records.length > 0) {
              //项目负责人拼接数据
              let projectLeadingTextTemp = []
              let projectLeadingIdTemp = []

              //生产团队拼接数据
              let teamTextTemp = []
              let teamIdTemp = []

              //添加任务信息子表数据
              res.result.records.forEach((item) => {
                this.taskDataSource.push({
                  category: item.id,
                  contractProportion: item.contractRate,
                  allocationAmount: item.contractAmount,
                  productionTeamId: item.productTeam,
                  projectHead: item.projectLeading,
                })
                //项目负责人文本
                projectLeadingTextTemp.push(filterMultiDictText(this.dictOptions['empId'], item.projectLeading + ''))
                //项目负责人id
                projectLeadingIdTemp.push(item.projectLeading)

                //生产团队id
                teamIdTemp.push(item.productTeam)
                //生产团队文本
                teamTextTemp.push(filterMultiDictText(this.dictOptions['teamId'], item.productTeam + ''))
              })
              //项目负责人逗号拼接
              let projectLeadingIds = projectLeadingIdTemp.join(',')
              let projectLeadingText = projectLeadingTextTemp.join(',')
              this.projectLeadingToSubTable = projectLeadingIds
              this.projectLeadingToSubTableText = projectLeadingText

              //生产团队逗号拼接
              let productTeamId = teamIdTemp.join(',')
              let productTeamText = teamTextTemp.join(',')
              this.$set(this.model, 'productionTeam', productTeamText)
              this.$set(this.model, 'productionTeamId', productTeamId)
            }
          }
        })
      }

      //切换项目清空子表弹窗提示
      if (this.projectIdBackups && this.projectIdBackups !== backItem.id) {
        // let detailList = this.$refs.disclaimerDetailList.submitForm()
        // if (detailList.length > 0){
        const that = this

        uni.showModal({
          title: '确认切换项目',
          content: '切换项目会清空免责信息数据，您确定要切换吗',
          success: async (res) => {
            if (res.confirm) {
              //确认后进行改变
              that.projectIdBackups = that.model.projectId

              //清空免责信息子表数据
              that.formData = []
              //   that.$refs.disclaimerDetailList.dataSource = []

              that.projectLeadingToSubTable = ''
              that.projectLeadingToSubTableText = ''
              //清空任务信息子表数据
              that.taskDataSource = []

              //带出项目编号
              that.$set(that.model, 'projectNo', backItem.finalNo)

              //带出项目真实名称
              that.$set(that.model, 'projectName', backItem.projectName)

              //带出项目承接人
              that.$set(that.model, 'undertaker', backItem.undertaker)

              //带出经营团队
              that.$set(that.model, 'managementTeam', backItem.teamName)

              //带出业绩归属年度
              that.$set(that.model, 'year', backItem.year)

              //带出签订单位
              that.$set(that.model, 'signUnit', backItem.signUnit)

              //带出业主单位
              that.$set(that.model, 'ownerUnit', backItem.ownerUnit)

              //请求合同档案
              await queryContractFinal({ xmmc: backItem.id, htlx: 1 }).then((res) => {
                if (res.success) {
                  if (res.result.records.length > 0) {
                    //查出收款合同
                    that.$set(that.model, 'contractId', res.result.records[0].id)
                    //带出合同真实名称
                    that.$set(that.model, 'contractName', res.result.records[0].htmc)
                    //带出本次合同额
                    that.$set(that.model, 'contractAmount', res.result.records[0].bchte)

                    var contractIdTemp = res.result.records[0].id
                    //查询收款进度中节点信息
                    listForAudit({ contractId: contractIdTemp, contractType: '1' }).then((res) => {
                      if (res.success) {
                        let { records } = res.result
                        if (records && records.length > 0) {
                          let firstItem = records[0]
                          //从进度管理-收款进度主表中带出实收款总额
                          that.$set(that.model, 'totalAmountReceived', firstItem.realCollectionPaymentMoney)
                        }
                      }
                    })
                  } else {
                    //没有收款合同则收款合同带出的信息置空
                    that.$set(that.model, 'contractId', '') //合同id置空
                    that.$set(that.model, 'contractName', '') //合同名称置空
                    that.$set(that.model, 'contractAmount', '') //本次合同额置空
                    that.$set(that.model, 'totalAmountReceived', '') //收款进度-实收款总额置空
                  }
                }
              })

              //请求任务档案根据项目id
              await queryPageList({ projectId: backItem.id }).then((res) => {
                if (res.success) {
                  if (res.result.records.length > 0) {
                    //项目负责人拼接数据
                    let projectLeadingTextTemp = []
                    let projectLeadingIdTemp = []

                    //生产团队拼接数据
                    let teamTextTemp = []
                    let teamIdTemp = []

                    //添加任务信息子表数据
                    res.result.records.forEach((item) => {
                      that.taskDataSource.push({
                        category: item.id,
                        contractProportion: item.contractRate,
                        allocationAmount: item.contractAmount,
                        productionTeamId: item.productTeam,
                        projectHead: item.projectLeading,
                      })
                      //项目负责人文本
                      projectLeadingTextTemp.push(filterMultiDictText(that.dictOptions['empId'], item.projectLeading + ''))
                      //项目负责人id
                      projectLeadingIdTemp.push(item.projectLeading)

                      //生产团队id
                      teamIdTemp.push(item.productTeam)
                      //生产团队文本
                      teamTextTemp.push(filterMultiDictText(that.dictOptions['teamId'], item.productTeam + ''))
                    })
                    //项目负责人逗号拼接
                    let projectLeadingIds = projectLeadingIdTemp.join(',')
                    let projectLeadingText = projectLeadingTextTemp.join(',')
                    that.projectLeadingToSubTable = projectLeadingIds
                    that.projectLeadingToSubTableText = projectLeadingText

                    //生产团队逗号拼接
                    let productTeamId = teamIdTemp.join(',')
                    let productTeamText = teamTextTemp.join(',')
                    that.$set(that.model, 'productionTeam', productTeamText)
                    that.$set(that.model, 'productionTeamId', productTeamId)
                  }
                }
              })

              //   that.$refs.disclaimerDetailList.showAdd = false
            } else if (res.cancel) {
              that.model.projectId = that.projectIdBackups
            }
          },
        })
      }
    },
    // 选择实施部门
    onExecuteDepartInput(item) {},
    initDictConfig() {
      initDictOptions('erp_omc_team_manager,alias_name,id').then((res) => {
        if (res.success) {
          this.$set(this.dictOptions, 'teamId', res.result)
        }
      })
      initDictOptions('erp_omc_project_task,category_name,id').then((res) => {
        if (res.success) {
          this.$set(this.dictOptions, 'categoryName', res.result)
        }
      })
      initDictOptions('erp_employee_file,name,id').then((res) => {
        if (res.success) {
          this.$set(this.dictOptions, 'empId', res.result)
        }
      })
      initDictOptions('erp_omc_project,project_name,id').then((res) => {
        if (res.success) {
          this.$set(this.dictOptions, 'projectId', res.result)
        }
      })
      //款项名称
      initDictOptions('erp_progress_payment_node,node_name,id').then((res) => {
        if (res.success) {
          this.$set(this.dictOptions, 'paymentName', res.result)
        }
      })
      //豁免类型
      initDictOptions('exemption_type').then((res) => {
        if (res.success) {
          this.$set(this.dictOptions, 'exemptionType', res.result)
        }
      })
    },
    handleCopyForm([item, index]) {
      this.formData.push({
        ...item,
      })
      this.$u.toast('复制成功')
    },
    handleEditForm([item, index]) {
      this.basicForm = { ...item }
      this.index = index
      this.showFormModal = true
      this.$nextTick(() => {
        this.openFormModal()
      })
    },
    handleRemoveForm(item) {
      this.formData = this.formData.filter((i) => i !== item)
    },
    closeFormModal() {
      this.$refs.dataForm.reset()
      this.basicForm = {}
      this.index = null
      this.showFormModal = false
    },
    openFormModal() {
      this.$refs.dataForm.basicForm = this.basicForm
    },
    addForm() {
      this.index = null
      this.showFormModal = true
    },
    // 新增物料
    handleAddMember() {
      if (!this.model.contractId) {
        this.$u.toast('请确保您选择了项目并且该项目有收款合同！')
        return
      }
      this.index = null
      this.showFormModal = true
    },
    /**
     * 子表单新增点击确认
     */
    handleFormSubmit([data, index]) {
      this.showFormModal = false
      if (typeof index === 'number') {
        this.$set(this.formData, index, data)
      } else {
        this.formData.push(data)
      }
      // this.closeFormModal()
    },
    // 获取单据编号
    async initBillNo() {
      const res = await gainBillNo({})
      this.model.billNo = res.result
    },
    // 初始化新增需要的数据
    initForm() {
      this.model.proposer = this.userInfo.empId //当前登录人
      this.model.proposerDeptId = this.userInfo.deptId //当前登录人部门
      this.model.createTime = moment().format('YYYY-MM-DD HH:mm:ss')
    },
    //查询任务信息子表数据
    async initInfo() {
      const response = await info({ id: this.id })
      const data = response?.result || {}
      this.model = Object.assign({}, data)
      this.projectIdBackups = this.model.projectId
    },
    //查询任务信息子表数据
    async initDataList() {
      const response = await queryTaskInfoList({ mainId: this.id, pageSize: 999 })
      const data = response.success ? response.result.records : []
      this.taskDataSource = data
    },
    //加载免责信息子表数据
    async initDisclaimerDetailList() {
      const response = await queryDisclaimerDetailList({ mainId: this.id, pageSize: 999 })
      const data = response.success ? response.result.records : []
      this.formData = data
      setTimeout(() => {
        this.$refs.collapseView.init()
      }, 500)
    },
    validateForm() {
      return this.$refs.form.validate().then(async () => {
        if (!this.formData.length) {
          this.$u.toast('请添加免责信息！')
          return Promise.reject('请添加免责信息！')
        }
        return Promise.resolve()
      })
    },
    setBpmBizTitle() {
      var projectName = filterMultiDictText(this.dictOptions['projectId'], this.model.projectId + '')
      this.$set(
        this.model,
        'bpmBizTitle',
        '回款免责申请单-' + (this.model.projectId?projectName +'-':'') +this.userInfo?.employee?.name +'-' +moment(this.model.createTime).format('YYYY-MM-DD'),
      )
    },
    async onSubmit() {
      await this.validateForm()
      this.isSubmit = true
      await this.setBpmBizTitle()

      //免责信息
      let disclaimerInfoList = this.formData
      //任务信息
      let taskInfoList = this.taskDataSource
      try {
        this.loading = true
        var url = ''
        if (this.id) {
          url = edit
        } else {
          url = add
        }
        const response = await url({
          ...this.model,
          disclaimerInfoList,
          taskInfoList,
        })
        if (response.success) {
          // var that = this
          this.isSubmit = true
          // 获取流程列表
          if (this.model.id) {
            this.getProcessList(this.model.id)
          } else {
            // 判断添加的时候是否有返回id值
            if (response.result) {
              this.getProcessList(response.result)
            }
          }
          this.$refs.uToast.show({
            message: response.message,
            type: 'default',
            complete() {
              // that.isSubmit = false
            },
          })
        }
      } finally {
        this.loading = false
      }
    },
    // 获取流程列表
    getProcessList(id) {
      if (this.isSubmit) {
        this.$refs.processConfig.showPopup = true
        this.$refs.processConfig.formUrl = this.formUrl
        this.$refs.processConfig.formUrlMobile = this.formUrlMobile
        this.$refs.processConfig.flowCode = this.flowCode
        this.$refs.processConfig.edit(id, this.processId, this.beanName)
      }
    },
    async onDraft() {
      // await this.validateForm()
      this.isSubmit = true
      await this.setBpmBizTitle()

      //免责信息
      let disclaimerInfoList = this.formData
      //任务信息
      let taskInfoList = this.taskDataSource
      try {
        this.loading = true
        var url = ''
        if (this.id) {
          url = edit
        } else {
          url = add
        }
        const response = await url({
          ...this.model,
          disclaimerInfoList,
          taskInfoList,
        })
        if (response.success) {
          this.isSubmit = true
          this.$refs.uToast.show({
            message: response.message,
            type: 'default',
            complete() {
              this.isSubmit = false
              if (getCurrentPages().length > 1) {
                uni.navigateBack()
              } else {
                uni.reLaunch({
                  url: '/pages/home/home',
                })
              }
            },
          })
        }
      } finally {
        this.loading = false
      }
    },
  }
}
</script>
    
    <style scoped lang="scss">
@import url('@/assets/inputStyle.scss');
.trip-form-data {
  ::v-deep {
    .u-form-item__body {
      padding-top: 2px;
      padding-bottom: 2px;
    }
  }
}
.checkbox-item {
  display: flex;
  align-items: center;
}
</style>
    